'''
字典：以键值对的形式出现，键时不能重复，value是可以重复，无序的
定义：{key1:value1,key2:value2},dict()-空的字典
key:数字，字符串，布尔，元组
value:所有类型都可以
'''
dict1 = {1:2,2.2:1,True:False,"xm":1}
print(dict1)
dict1 = {"name":"杨一","age":33,"sex":"男"}
print(dict1,type(dict1))
dict2 = {"yangyi":{15178831596,15632569845}}
print(dict2,type(dict2))

#获取value，通过key去获取
dict3 = {100012:"牙膏","牙膏":9.9,"100013":{"方便面","碗","卤蛋","火腿肠"},"苹果":6}
value = dict3[100012]
print(value)
# key不存在时获取value会报错
# print(dict3[100011])
# key不存在时，获取不报错
value = dict3.get(100012,"默认值")
print(value)
# 获取字典里所有key值
keys = dict3.keys()
print(keys)

# 获取字典里所有value值
values = dict3.values()
print(values)

# 获取字典里所有的数据
items= dict3.items();
print(items)

#循环遍历字典
# 利用keys遍历获取value
for key in dict3.keys():
    print(key,dict3[key])

# items
for item in dict3.items():
    # print(item,type(item))
    print(f"key为：{item[0]},value为：{item[1]}")
# 获取key-value
for key in dict3:
    print(f"key为：{key},value为：{dict3[key]}")

# pop
print(dict3.pop("100013"))
print(dict3)

# clear {}
print(dict3.clear())

